﻿<%@ WebHandler Language="C#" Class="StoreManagementSystem.TestSite.maphandler" %>
using System;
using System.Web;
using System.Collections.Generic;
using System.Web.Security;
using StoreManagementSystem.DataAccessLayer;
using StoreManagementSystem.DomainObjects;

namespace StoreManagementSystem.TestSite
{
    public class maphandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            string str = "";
            List<Aisle> aisles = new List<Aisle>();
            
            DataAccessLayer.SQLDAOFactory doaFactory;
            doaFactory = new DataAccessLayer.SQLDAOFactory(new DataAccessLayer.SQLDataProvider("MySQLConnectionString"));
            IDataAccessObject<DomainObjects.Entity> DAO = doaFactory.createDAO("aisle");

            SQLAisleDAO aisleDAO = (SQLAisleDAO) DAO;
            aisles = aisleDAO.getAisles();

            str = Newtonsoft.Json.JsonConvert.SerializeObject(aisles, Newtonsoft.Json.Formatting.Indented);

            context.Response.ContentType = "application/json";
            context.Response.Write(str);
        }

        public bool IsReusable
        {
            get { return false; }
        }
    }
}